package cn.iocoder.springboot.lab03.kafkademo.controller;

import cn.iocoder.springboot.lab03.kafkademo.consumer.Demo04Consumer;
import cn.iocoder.springboot.lab03.kafkademo.message.Demo04Message;
import cn.iocoder.springboot.lab03.kafkademo.producer.Demo01Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.concurrent.ExecutionException;

/**
 * @Author：YH
 * @Description：
 * @Date:Created in 2022/1/3 1:32
 */

@Controller
public class ControllerTest {

    @Autowired
    Demo01Producer demo01Producer;

    @Autowired
    Demo04Consumer demo04Consumer;

    @GetMapping(value = "/test")
    @ResponseBody
    public String createOrderTest() throws ExecutionException, InterruptedException {
        //SendResult sendResult = demo01Producer.syncSend(1);
        demo04Consumer.onMessage(new Demo04Message(2));
        //ListenableFuture<SendResult<Object, Object>> sendResultListenableFuture = demo01Producer.asyncSend(2);
        return "ok";
    }


}

